<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<?php
    //一，接受form表单数据并处理;post提交方式数据是以关联数组的形式存储在$_post全局数组里
    echo'hello boss';
    var_dump($_POST);
    echo "<br>";
        $username = $_POST["username"];
        $password = $_POST["password"];
        $verify = $_POST["verify"]; 
    echo "$username,$password,$verify<br>";

    //二，操作数据表并返回结果

    //1.连接数据库
    $link = mysqli_connect("localhost","root","");//创建一个mysql的连接
    mysqli_select_db($link,"itcast");//选择数据库
    mysqli_set_charset($link, "utf8");//设置数据库连接资源字符集

    //2.写sql模板
    $sql = "SELECT *FROM shop_user WHERE username = '$username' AND password = '$password';";
    echo "$sql<br>";

    //3.执行查询并返回结果
    $result = mysqli_query($link, $sql);
    var_dump($result);
    echo "<br>";
    $row = mysqli_fetch_row($result);
    var_dump($row);
    echo "<br>";

    //三，处理返回结果
    if($row){
        echo "<script>alert('登录成功！！！');location.href='index.php';</script>";
    }else{
        echo "<script>alert('登录出错！！！');location.href='login.php';</script>";
    }
?>
</body>
</html>